package com.chd.ledger_server.service.impl;

import com.chd.ledger_server.entity.VLedgerComprehensive;
import com.chd.ledger_server.dao.VLedgerComprehensiveDao;
import com.chd.ledger_server.service.VLedgerComprehensiveService;
import com.chd.ledger_server.domain.PageDto;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;
import java.util.List;

/**
 * (VLedgerComprehensive)表服务实现类
 *
 * @author makejava
 * @since 2025-07-26 15:44:18
 */
@Service("vLedgerComprehensiveService")
public class VLedgerComprehensiveServiceImpl implements VLedgerComprehensiveService {
    @Resource
    private VLedgerComprehensiveDao vLedgerComprehensiveDao;

    /**
     * 通过ID查询单条数据
     *
     * @return 实例对象
     */
    @Override
    public VLedgerComprehensive queryById(Integer ledId) {
        return this.vLedgerComprehensiveDao.queryById(ledId);
    }

    /**
     * 分页查询
     */
    @Override
    public PageInfo queryAllVLedgerComprehensivesByPage(PageDto pageDto) {
        //空值处理
        if (pageDto.getPage() == null || pageDto.getSize() == null) {
            pageDto.setPage(1);
            pageDto.setSize(10);
        }
        PageHelper.startPage(pageDto.getPage(), pageDto.getSize());
        List<VLedgerComprehensive> list = vLedgerComprehensiveDao.queryAll(pageDto.getVledger());
        PageInfo<VLedgerComprehensive> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

}
